﻿//-----------------------------------------------------------------------
// <copyright file="Logger.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation.
// All rights reserved.
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
// </copyright>
// <author>Yogesh M Joshi</author>
// <email>ymjoshi@live.com</email>
// <date>16-May-2011</date>
//-----------------------------------------------------------------------

namespace SmartTag.Application.CommandLine
{
    using System;
    using System.Threading;

    /// <summary>
    /// Log messages on command line
    /// </summary>
    internal static class Logger
    {
        /// <summary>
        /// Log message on console
        /// </summary>
        /// <param name="message">Message to log</param>
        public static void LogMessage(string message)
        {
            Console.WriteLine(
                "{0} {1}\t Thread # {2}\t{3}",
                DateTime.Now.ToShortDateString(),
                DateTime.Now.ToShortTimeString(),
                Thread.CurrentThread.ManagedThreadId,
                message);
        }

        /// <summary>
        /// Log error on console
        /// </summary>
        /// <param name="message">Error to log</param>
        public static void LogError(string message)
        {
            LogMessage(message);
        }

        /// <summary>
        /// Log exception on console
        /// </summary>
        /// <param name="message">Message to log</param>
        /// <param name="ex">Exception to log</param>
        public static void LogException(string message, Exception ex)
        {
            LogMessage(message);
            Console.WriteLine("Exception : {0}", ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
    }
}
